package com.project.controller;

import com.project.bean.UserBean;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.net.http.HttpRequest;
import java.time.LocalDate;
import java.util.List;

@Controller
//@RequestMapping("test")
public class TestController {

    @RequestMapping("/")
    public String testThymeleaf(HttpServletRequest req, Model model){

       req.setAttribute("age",20);
        req.setAttribute("name","张三");
        model.addAttribute("phone","12345676432");//功能一样的

        model.addAttribute("user",new UserBean(6,"何用","12345543254", LocalDate.parse("2000-01-09")));

        req.setAttribute("grade",80);

        req.setAttribute("list", List.of(new UserBean(1,"刘勇","12345663254", LocalDate.parse("1998-01-09")),
                new UserBean(2,"陈琦","12345543224", LocalDate.parse("2001-01-09")),
                new UserBean(3,"李四","12215543254", LocalDate.parse("2000-08-09")),
                new UserBean(4,"细雨","12345543254", LocalDate.parse("2001-04-09")),
                new UserBean(5,"秋风","12215599254", LocalDate.parse("2002-08-09"))));

        req.setAttribute("totalPage",6);

        return "html/index.html";
    }

}
